#include "basicinfo.h"

#include <stdio.h>
#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#define UINT64_C
extern "C"
{
#endif
#include "libavutil/ffversion.h"
#include "libavcodec/avcodec.h"
#ifdef __cplusplus
}
#endif

#include <QDebug>

/* 输出FFmpeg的版本和解码器的版本。*/
void showVersion()
{
    unsigned codecVer = avcodec_version();
    int ver_major,ver_minor,ver_micro;
    ver_major = (codecVer>>16)&0xff;
    ver_minor = (codecVer>>8)&0xff;
    ver_micro = (codecVer)&0xff;
    QString verStr = QString::number(ver_major) + "." + QString::number(ver_minor) + "." + QString::number(ver_micro);
//    printf("FFmpeg version is: %s, avcodec version is: %d\n.",FFMPEG_VERSION,codecVer);
    qDebug() << "FFmpeg version is: " << FFMPEG_VERSION << ", avcodec version is: " << verStr;
}

/* 获取ffmpeg支持的硬件解码器类型。*/
void hwdDeviceType()
{
    AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE; //ffmpeg支持的硬件解码器
    QList<int> m_HWDeviceTypes;
    QStringList strTypes;
    //遍历支持的设备类型。
    while ((type = av_hwdevice_iterate_types(type)) != AV_HWDEVICE_TYPE_NONE)
    {
        m_HWDeviceTypes.append(type);
        //获取AVHWDeviceType的字符串名称。
        const char* ctype = av_hwdevice_get_type_name(type);
        if(ctype)
        {
            strTypes.append(QString(ctype));
        }
    }
    qDebug() << "支持的硬件解码器：" << strTypes;
}
